
import React from 'react'
import styl from './index.module.styl'
class DateArea extends React.Component {

    constructor(props) {
        super(props)
        this.state = {
            currentDate: new Date()
        }
    }

    tick = () => {
        this.setState({
            currentDate: new Date()
        })
    }

    componentDidMount() {
        this.timer = setInterval(this.tick, 1000)
    }

    componentWillUnmount() {
        clearInterval(this.timer)
    }

    render() {
        return (
            <p className={styl.dateArea} >
                {this.state.currentDate.toLocaleString()}
            </p>
        )
    }
}

export default DateArea